package com.eusoft.grades.school;
/**
 * @author Nick Eubanks
 * 
 * Copyright (C) 2010 Android Infinity (http://www.androidinfinity.com)
 *
 */
import java.io.Serializable;
import java.util.ArrayList;

/**
 * 
 * @author Nick Eubanks
 */
public class Student implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5260845419454837038L;

	public int currentSem = 0;
	
	public int ITEM = -1;

	public String name = "", studentId = "", ID = "", clas = "";

	public GradeScale overallScale = new GradeScale();

	public double prevGPA = 0, prevCredits = 0;

	public ArrayList<TestScore> testscores = new ArrayList<TestScore>();
	
	public ArrayList<Semester> semesters = new ArrayList<Semester>();

        public Student(String name){
            this.name = name;
        }

        public Student(){
            
        }

	public double calculateNewCredits() {
		double curCredits = 0; // TODO: Calculate Total Number of Credits

		for (Semester s : semesters) {
			curCredits += s.calculateSemesterHours();
		}

		return curCredits;
	}

	public double calculateNewGPA() {
		double curGPA = 0.0; // TODO: Calculate Total GPA
		double totalHours = 0;
		for (Semester s : semesters) {
			double semGPA = s.calculateSemesterGPA();
			double semHours = s.calculateSemesterHours();
			curGPA += semGPA * semHours;
			totalHours += semHours;
		}

		if (totalHours != 0)
			return (curGPA / totalHours);
		else
			return 0.0;
	}

	public double calculateTotalCredits() {
		double curCredits = 0;

		for (Semester s : semesters) {
			curCredits += s.calculateSemesterHours();
		}

		return (curCredits + prevCredits);
	}

	public double calculateTotalGPA() {
		double newGPA = this.calculateNewGPA();
		double newHours = this.calculateNewCredits();
		if ((prevCredits + newHours) != 0)
			return ((newGPA * newHours) + (prevGPA * prevCredits))
					/ (prevCredits + newHours);
		else
			return 0.0;
	}

}
